(function () {
  let obj = {
    // 生成新数组 二维数组 
    chunk: function (arr, size = 1) {
      if (!Array.isArray(arr)) {
        return new Error(arr + ' is no Array')
      }
      let result = []
      for (let index = 0; index < arr.length; index += size) {
        result.push(arr.slice(index, index + size))
      }
      return result;
    },
    // 返回非假数组 新数组
    compact: function (arr) {
      if (!Array.isArray(arr)) { return (new Error('error')) }
      let result = []
      arr.map(item => {
        if (item) result.push(item)
      })
      return result

    },
    // concta 链接数组
    concta: function (arr, ...argus) {
      if (!Array.isArray(arr)) { return (new Error('error')) }
      return arr.concat(...argus)
    },
    // 过滤数组中指定值
    difference: function (arr, ...argus) {
      if (!Array.isArray(arr)) { return (new Error('error')) }
      let result = []
      arr.filter(item => {
        if (!argus.includes(item)) {
          result.push(item)
        }
      })
      return result
    },
    // drop(arr,n=1) 切片数组 
    drop: function (arr, size = 1) {
      arr.splice(0, size)
      return arr
    },
    dropRight: function (arr, size = 1) {
      arr.splice(-size)
      return arr
    }
  };




  window._ = {}
  for (const key in obj) {
    if (Object.hasOwnProperty.call(obj, key)) {
      _[key] = obj[key]
    }
  }
})(window)